{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "copy() 复制 不等于赋值，复制可等价于切片[:] 2.enumerate\n",
    "查询字典方式\n",
    "print(\"stu10003\" in info_03)\n",
    "if \"stu10006\" in info_03:\n",
    "    print(info_03[\"stu10006\"])\n",
    "else:\n",
    "    print(\"查询的key不存在\")\n",
    "    for i in vowels: # for循环的第二个元素，决定了我们循环的内容\n",
    "    print(i)     #  循环的列表，每个元素在一行打印\n",
    "    字典的重要属性：\n",
    "结构：key:value（键值对） 1.字典是无序的，我们通过键(key)去查找值(value)，就好像list用索引(index)查找值(value)一样，只不过字典的“索引”被定义了名字 2.字典对key的定义有一定的要求：key是由\"不可变\"的数据结构才可以定义，list是不能作为key来定义的。 3.字典的key是唯一的，字典的值value也可以不唯一。（list的值是唯一的么？） 4.字典的创建\n",
    "\n",
    "users = [\n",
    "    [\"hy\",20,\"te\",100],\n",
    "    [\"ss\",21,\"te\",200]\n",
    "\n",
    "]\n",
    "# 试对比：\n",
    "users_dict = {\n",
    "    \"hy\":[20,\"te\",100],\n",
    "    \"ss\":[21,\"te\",200]\n",
    "}\n",
    "# 查询qian的信息：\n",
    "users[1]\n",
    "['hy', 20, 'te', 100]\n",
    "users_dict\n",
    "['ss''21', 'te', 200]\n",
    "\n",
    "\n",
    "\n",
    "运用字典增加的方式新建字典:\n",
    "info_03 = {} info_03[key1] = value1 ,info_03[key2] = value2 ...\n",
    "info = {\n",
    "    \"stu10001\":\"hy\",\n",
    "    \"stu10002\":\"yue\",\n",
    "    \"stu10003\":\"ss\",\n",
    "#     \"stu10004\":\"ji\",\n",
    "}\n",
    "print(info)\n",
    "print(type(info))\n",
    "{'stu10001': 'hy', 'stu10002': 'yue', 'stu10003': 'ji'}\n",
    "<class 'dict'>\n",
    "info_02 = dict(\n",
    "    stu10001=\"hy\",\n",
    "    stu10002=\"yue\",\n",
    "    stu10003=\"ji\",\n",
    ")\n",
    "print(info_02)\n",
    "print(type(info_02))\n",
    "{'stu10001': 'hy', 'stu10002': 'yue', 'stu10003': 'ji'}\n",
    "<class 'dict'>\n",
    "info_03 = {} # 新建空字典\n",
    "info_03[\"stu10001\"] = \"hy\"\n",
    "info_03[\"stu10002\"] = \"yue\"\n",
    "info_03[\"stu10003\"] = \"ji\"\n",
    "print(info_03)\n",
    "print(type(info_03))\n",
    "{'stu10001': 'hy', 'stu10002': 'yue', 'stu10003': 'ji'}\n",
    "<class 'dict'>\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}